import torch
import torchvision
from torchvision import transforms
import matplotlib.pyplot as plt
from IPython import display
import time
import sys 
import numpy as np
sys.path.append('..')
from IPython import display
def get_fashion_mnist_labels(labels):
    text_labels=['t-shirts','trouser','pullover','dress','coat','sandal','shirt','sneaker','bag','ankle','boot']
    return [text_labels[int(i)] for i in labels]
# 设置图片尺寸
def setfigsize(figsize=(3.5,2.5)):
    use_svg_display()
    plt.rcParams['figure.figsize']=figsize
# 矢量图显示

def use_svg_display():
    display.set_matplotlib_formats('svg')
def sgd(params,lr,batch_size):
    for param in params:
        param.data-=lr*param.grad/batch_size  
def show_fashion_mnist(images,labels):
    use_svg_display()
    _,figs=plt.subplot(1,len(images),figsize=(12,12))
    for f,img,lbl in zip(figs,images,labels):
        f.imshow(img.view(28,28)).numpy()
        f.set_title(lbl)
        f.axes.get_xaxis().set_visible(False)
        f.axes.get_yaxis().set_visible(False)
    plt.show()